home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_01_01
/
1n01041a
< prev
next >
Wrap
Text File
|
1990-05-16
|
892b
|
32 lines
/*
** Figure 4
**
** Tee's all standard output to the printer.
**
** Parameters: None
**
** Returns: 0 if operation was successful.
** -1 if stdout or stdin is redirected.
**
** Side effects: Flushes the keyboard buffer
*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <io.h>
#ifdef __ZTC__ /* Zortech C/C++ doesn't support ungetch() */
#include <mflconio.h> /* Part of the MFLZT shareware library */
#endif
int cdecl prtoggle(void)
{
if (!isatty(fileno(stdin)) || !isatty(fileno(stdout)))
return -1;
while (kbhit()) /* Flush the keyboard buffer */
getch();
ungetch('P' - 64); /* Stuff a Ctrl-P into the buffer */
system(""); /* Let COMMAND.COM do the work */
return 0;
}